package com.controller;

import com.vo.EmpVO;
import com.vo.ResponseVO;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/emps")
@Api("员工")
public class EmpController {
    @ApiOperation(value = "获取所有员工", httpMethod = "GET")

    @GetMapping("")
    public ResponseVO<List<EmpVO>> getAll() {
        List<EmpVO> list = new ArrayList<>();
        EmpVO empVO = new EmpVO(1, "aaa");
        EmpVO empVO2 = new EmpVO(2, "bb");
        EmpVO empVO3 = new EmpVO(3, "cc");
        list.add(empVO);
        list.add(empVO2);
        list.add(empVO3);

        ResponseVO<List<EmpVO>> responseVO = new ResponseVO<>(200, "ok", list);
        return responseVO;
    }

    @PostMapping("")
    @ApiOperation(value = "插入员工", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "empVO", type = "EmpVO")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
            @ApiResponse(code = 500, message = "失败")
    })
    public ResponseVO<Boolean> insert(@RequestBody EmpVO empVO) {

        System.out.println("----insert----");
        System.out.println(empVO);
        return new ResponseVO<>(200, "ok", true);

    }
}
